/**
 * 
 */
package org.ucn.dmaa0914.gruppe6;

/**
 * @author Kim Johannsen
 * @version 02-02-2015 
 */
public class CustomerCtr extends CrudController<Customer> {
	private static CustomerCtr instance;
	private int currentCustomer;
	
	public static CustomerCtr getInstance()
	{
		if( instance == null )
			instance = new CustomerCtr();
		
		return instance;
	}

	@Override
	protected SearchFilter<Customer> getSearchFilter() {
		return new CustomerSearchFilter();
	}

	@Override
	protected Customer newObject() {
		return new Customer();
	}

	public int getCurrentCustomer() {
		return currentCustomer;
	}
	
	public void setCurrentCustomer(int id) {
		currentCustomer = id;
	}

	@Override
	public String format(int id) {
		return find(id).getName() + " (" + find(id).getPhone() + ")";
	}
	
	public void updateCustomer(int id, String name, String phone)
	{
		find(id).setPhone(phone);
		find(id).setName(name);
	}
}
